From e697c1c3c3ff772721ec5a6161c30aa8b114d5ac Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 16 Jan 2004 14:41:53 +0000 Subject: [PATCH] Implement callback in libjeeps for waypoint output, use that for status in garmin.c --- gpsbabel/garmin.c | 18 +++++++++++++----- gpsbabel/jeeps/gpsapp.c | 10 +++++++--- gpsbabel/jeeps/gpsapp.h | 2 +- gpsbabel/jeeps/gpscom.c | 4 ++-- gpsbabel/jeeps/gpscom.h | 2 +- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 51d3beb1f..f1f4bf690 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -304,6 +304,17 @@ sane_GPS_Way_New(void) return way; } +static int +waypt_write_cb(GPS_PWay *way) +{ + static int i; + + if (global_opts.verbose_status) { + fprintf(stdout, "%d\r", ++i*100/waypt_count()); + fflush(stdout); + } + return 0; +} static void waypoint_write(void) @@ -350,13 +361,9 @@ waypoint_write(void) if (wpt->altitude != unknown_alt) { way[i]->alt = wpt->altitude; } - if (global_opts.verbose_status) { - fprintf(stdout, "%d\r", i*100/n); - fflush(stdout); - } i++; } - if ((ret = GPS_Command_Send_Waypoint(portname, way, n)) < 0) { + if ((ret = GPS_Command_Send_Waypoint(portname, way, n, waypt_write_cb)) < 0) { fatal(MYNAME ":communication error sending wayoints..\n"); } @@ -365,6 +372,7 @@ waypoint_write(void) } if (global_opts.verbose_status) { fprintf(stdout, "\r\n"); + fflush(stdout); } xfree(way); } diff --git a/gpsbabel/jeeps/gpsapp.c b/gpsbabel/jeeps/gpsapp.c index 6fff83157..f75b767de 100644 --- a/gpsbabel/jeeps/gpsapp.c +++ b/gpsbabel/jeeps/gpsapp.c @@ -27,7 +27,6 @@ #include #include - static int32 GPS_A000(const char *port); static void GPS_A001(GPS_PPacket packet); @@ -695,7 +694,7 @@ int32 GPS_A100_Get(const char *port, GPS_PWay **way) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n) +int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n, int (*cb)()) { UC data[GPS_ARB_LEN]; int32 fd; @@ -724,6 +723,11 @@ int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n) for(i=0;i